Vue.component("myheader", {
    template:`
            <div id="header" class="wrap">
                <div id="logo">
                    <img src="images/logo.gif"/>
                </div>
                <div class="search">
                    <a href="login.html" v-if="!loginedUser">登录</a>
                    <a href="register.html" v-if="!loginedUser">注册</a>
                    <span v-if="loginedUser">欢迎：{{loginedUser.username}}</span>
                    <label class="ui-green" v-if="loginedUser"><input @click="add()" type="button" name="search"
                                                       value="发布房屋信息"/></label>
                    <label class="ui-green" v-if="loginedUser"><input type="button" name="search" value="退       出"
                                                       @click="logout"/></label>
                </div>
            </div>`
    ,
    data(){
        return{
            loginedUser: null
        }

    },
    created(){
        this.refreshLoginedUser();

    },
    methods:
        {
            logout(){
                axios.get("/user/logout").then(res=>{
                    this.loginedUser = null;
                    alert(res.data.msg);
                })
            },
            refreshLoginedUser(){
                axios.get("/user/getLoginedUser").then(res=>{
                    if (res.data.code){
                        this.loginedUser = res.data.data;
                    }
                })
            },
            add(){
                location.href="add.html"
            }
        }

})

Vue.component("myfooter",{
    template:`
    \t<div id="footer" class="wrap">
\t\t<dl>
\t\t\t<dt>青鸟租房 &copy 2015 源辰信息科技有限公司 湘ICP证1000001号</dt>
\t\t\t<dd>关于我们 · 联系方式 · 意见反馈 · 帮助中心</dd>
\t\t<>
\t</div>
    `
})
